<template>
  <div>
    这是第一个页面
    {{response.id}}
    <el-button type="primary" icon="el-icon-search" @click="handleIconClick">搜索</el-button>
  </div>
</template>

<script>
  import http from '@/utils/request';

  export default {
    name: 'page1',
    data() {
      return {
        id: 5,
        response: '',
        params: {
          name: 1,
          age: 20
        },
        pageNum: 1,
        pageSize: 2
      };
    },
    methods: {
      handleIconClick() {
        http.post('/pages', {
          pageNum: this.pageNum,
          PageSize: this.pageSize
        })
          .then(function (response) {
            console.log(response);
          })
          .catch(function (error) {
            console.log(error);
          });
      }
    },
    mounted() {
      let ids = this.id;
      http.get('/' + ids, {params: this.params}).then(response => {
        // console.log(response.data());
        this.response = response.data;
      }).catch(error => {
        console.log(error);
      });
      //
      // http.post('/pages', {
      //   pageNum: this.pageNum,
      //   PageSize: this.pageSize
      // })
      //   .then(function (response) {
      //     console.log(response);
      //   })
      //   .catch(function (error) {
      //     console.log(error);
      //   });
    }
  };
</script>

<style scoped>

</style>
